/*
 * @Author: DUST
 * @Date: 2023-05-28 14:57:27
 * @LastEditors: DUST
 * @LastEditTime: 2023-11-26 11:38:34
 * @FilePath: \business-card-system\server\app\model\Account.ts
 * @Description: 
 * undefined
 */

import { Column, DataType, Model, Table } from "sequelize-typescript";

@Table({
  tableName: "account",
  timestamps: true, // 自动维护时间
  freezeTableName: true, // 禁止修改表名，如果不写会把表名自动复数化，users
  paranoid: true, // 软删除
  indexes: [{ unique: true, fields: ["id", "unitId"] }],
})
export default class Account extends Model<Account> {
  @Column({
    type: DataType.INTEGER.UNSIGNED,
    autoIncrement: true,
    primaryKey: true,
    allowNull: false,
    comment: "用户id",
  })
  id!: number;

  @Column({
    type: DataType.INTEGER.UNSIGNED,
    allowNull: false,
    comment: "单位唯一标识",
  })
  unitId!: string;

  @Column({
    type: new DataType.STRING(128),
    allowNull: false,
    comment: "用户名"
  })
  username!: string;
  
  @Column({
    type: new DataType.STRING(128),
    allowNull: false,
    comment: "密码"
  })
  password!: string;

  @Column({
    type: new DataType.INTEGER({length: 2}),
    allowNull: false,
    defaultValue: 0,
    comment: "账号类型",
  })
  adminType!: number;

  @Column({
    type: new DataType.INTEGER({length: 2}),
    allowNull: false,
    defaultValue: 0,
    comment: "操作权限",
  })
  actionPower!: number;

  @Column({
    type: new DataType.INTEGER,
    comment: "菜单权限",
  })
  menuPower!: number;
  
}